﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.BoardUserStoryControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" x:Name="BoardControl">
    <UserControls:ScrumUserControl.Resources>
        <LinearGradientBrush x:Key="ItemBrush" StartPoint="0,0.5" EndPoint="1,0.5" >
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFD3D3D3" Offset="0.25" />
                <GradientStop Color="#FFAEBDC5" Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </UserControls:ScrumUserControl.Resources>
        <Grid Name="Grid" HorizontalAlignment="Stretch" Margin="0">           
    
        <Grid.Resources>
            
            <Converter:ConverterBoolVisibility x:Key="ConverterBoolVisibility"/>
            <Converter:ConverterNotBoolVisibility x:Key="ConverterNotBoolVisibility"/>


            <Style TargetType="{x:Type s:SurfaceCheckBox }">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type s:SurfaceCheckBox }">

                            <Border x:Name="innerBorder" Background="{StaticResource ItemClosed}" Height="30" Width="30">
                                <Border Background="Gray" Opacity="0.01">
                                </Border>
                            </Border>

                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter TargetName="innerBorder" Property="LayoutTransform">
                                        <Setter.Value>
                                            <RotateTransform Angle="45"/>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                            </ControlTemplate.Triggers>                            
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>            
          
        </Grid.Resources>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Name="FirstColumn" Width="300"/>        
        </Grid.ColumnDefinitions>
        <Grid HorizontalAlignment="Stretch" Grid.Column="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <s:SurfaceCheckBox  Grid.Column="0" x:Name="CheckBox"  IsChecked="{Binding ElementName=BoardControl, Path=BoardUserStory.IsExpaned}" />
            
            <UserControls:UserStoryControl x:Name="StoryControl" Grid.Column="1" Visibility="{Binding ElementName=BoardControl, Path=BoardUserStory.IsExpaned, Converter={StaticResource ConverterBoolVisibility}}"   VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MouseDown="OnMouseDown" TouchDown="OnTouchDown" />
            
            <Label Content="{Binding Name}"  Grid.Column="1" Visibility="{Binding ElementName=BoardControl, Path=BoardUserStory.IsExpaned, Converter={StaticResource ConverterNotBoolVisibility}}"></Label>
            <StackPanel Grid.Column="2" Grid.Row="0" Margin="0,0,-5,0" Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="Center">
                <UserControls:AddButton ButtonType="Task" HorizontalAlignment="Right" VerticalAlignment="Center" Click="OnAddTaskClick" />
                <UserControls:AddButton ButtonType="Bug" HorizontalAlignment="Right" VerticalAlignment="Center" Click="OnAddBugClick" Visibility="{Binding ElementName=BoardControl, Path=BoardUserStory.IsExpaned, Converter={StaticResource ConverterBoolVisibility}}"/>                
            </StackPanel>
        </Grid>
    </Grid>
</UserControls:ScrumUserControl>
